import moment from "moment";

export const convertTime = (date) => {
  if(date == null || date == ''){
    return ''
  }
  return moment(date).format('YYYY-MM-DD HH:mm:ss')
}

export const convertDate = (date) => { 
  if(date == null || date == ''){
    return ''
  }
  
  return moment(date).format('YYYY-MM-DD')
}

export const convertDate1 = (date) => { 
  if(date == null || date == ''){
    return ''
  }
  
  return moment(date).format('YYYY-MM-DD')
}
export function getAddDate(m) {
  return new Date(new Date().getTime() + m * 60 * 1000)
}

//转换s为 m ：s
export const convertTimes2MS = (times) => {
  const minutes = Math.floor(times / 60)
  const seconds = times - minutes * 60
  return minutes > 0 ? `${minutes} m ${seconds} s` : `${seconds} s`
}